home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- access;
- symbols
- RELEASE:1.3
- BETA:1.2;
- locks; strict;
- comment @ * @;
-
-
- 1.3
- date 91.06.21.12.48.43; author paul; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 91.05.23.21.32.34; author paul; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 91.05.22.18.57.19; author paul; state Exp;
- branches;
- next ;
-
-
- desc
- @flock() implemented as either lockf() or fcntl().
- @
-
-
- 1.3
- log
- @ANSI changes from Bruce Lilly.
- @
- text
- @/*
- * Copyright (c) 1989 Mark Davies
- * Copyright (c) 1990 Andy Linton
- * Copyright (c) 1990 Victoria University of Wellington.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement: ``This product includes software developed by the
- * Victoria University of Wellington, New Zealand and its contributors''
- * in the documentation or other materials provided with the distribution
- * and in all advertising materials mentioning features or use of this
- * software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
- #include "sendmail.h"
- #include <errno.h>
-
- #ifndef lint
- static char sccsid[] = "%W%";
- static char rcsid[] = "@@(#)$Id: flock.c,v 1.2 1991/05/23 21:32:34 paul Exp paul $";
- #endif
-
- #if defined(FCNTL_FLOCK) && defined(LOCKF_FLOCK)
- MULTIPLE_FLOCK_REPLACEMENTS_DEFINED
- #endif /* FCNTL_FLOCK && LOCKF_FLOCK */
-
- #ifdef FCNTL_FLOCK
-
- int
- flock(fd, operation)
- int fd, operation;
- {
- int op, ret;
- struct flock arg;
- extern int errno;
- # ifdef __STDC__
- extern int fcntl(int, int, ...);
- # else /* !__STDC__ */
- extern int fcntl();
- # endif /* __STDC__ */
-
- op = (LOCK_NB & operation) ? F_SETLK : F_SETLKW;
-
- arg.l_type = (LOCK_EX & operation) ? F_WRLCK :
- (LOCK_SH & operation) ? F_RDLCK : F_UNLCK;
- arg.l_whence = 0;
- arg.l_start = 0;
- arg.l_len = 0;
- arg.l_pid = 0;
-
- if ((ret = fcntl(fd, op, &arg)) == -1) {
- if (errno == EACCES || errno == EAGAIN)
- errno = EWOULDBLOCK;
- }
- return (ret);
- }
-
- #endif /* FCNTL_FLOCK */
- #ifdef LOCKF_FLOCK
-
- int
- flock(fd, operation)
- int fd, operation;
- {
- int op, ret;
- extern int errno;
- #ifdef __STDC__
- extern int lockf(int, int, long);
- #else /* !__STDC__ */
- extern int lockf();
- #endif /* __STDC__ */
-
- op = (LOCK_UN & operation) ? F_ULOCK :
- (LOCK_NB & operation) ? F_TLOCK : F_LOCK;
-
- if ((ret = lockf(fd, op, 0L)) == -1) {
- if (errno == EACCES || errno == EAGAIN)
- errno = EWOULDBLOCK;
- }
-
- return (ret);
- }
-
- #endif /* LOCKF_FLOCK */
- @
-
-
- 1.2
- log
- @Changes for permanent incorporation into the sendmail source directory.
- @
- text
- @d28 1
- a28 1
- static char rcsid[] = "@@(#)$Id: flock.c,v 1.1 1991/05/22 18:57:19 paul Exp paul $";
- d44 3
- d48 1
- d75 3
- d79 1
- d84 1
- a84 1
- if ((ret = lockf(fd, op, 0)) == -1) {
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d23 1
- a23 2
- #include <unistd.h>
- #include <sys/types.h>
- a24 1
- #include "flock.h" /* defines normally in <sys/file.h> */
- d28 1
- a28 1
- static char rcsid[] = "@@(#)$Id$";
- d31 3
- d35 1
- a35 1
- #if defined(F_SETLK) && defined(F_SETLKW)
- d62 2
- a63 1
- #else
- d84 1
- a84 2
- #endif /* F_SETLK && F_SETLKW */
-
- @
-